package java6;

import java.util.Arrays;

public class ArrayIntegerStack implements IntegerStack{
		private Integer arr[];
		private int top;
		public ArrayIntegerStack(int n){
			arr=new Integer[n];
		}
		public int size() {
			if(arr.length==0)
			return 0;
			return arr.length;
		}
		
		@Override
		public Integer push(Integer item) {
			if(item==null) return null;
			if(top==arr.length) return null;
			arr[top++]=item;
			return item;
		}
		
		@Override
		public Integer pop() {
			if(this.empty()){
			return null;
			}
			return this.top--;
		}
		
		@Override
		public Integer peek() {
			if(arr.length==0)
			return null;
			return this.top;
		}
		
		@Override
		public boolean empty() {
			if(arr.length==0)
			return false;
			return true;
		}
		@Override
		public String toString() {
			return "Arrays.toString(arr)";
		}
		
}
